package com.wei.czz.common.property;

import com.wei.czz.common.tool.BaseEntity;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2024-06-22 12:10:25
 * className: SmsProperty
 * version: 1.0
 * description:
 */
@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "sms")
@Validated
public class SmsProperty extends BaseEntity {

    /**
     * 是否开启短信发送[true-是 false-否]
     */
    @NotNull(message = "是否开启短信发送不能为空")
    private Boolean open;

    /**
     * 阿里云短信配置
     */
    @NotNull(message = "阿里云短信配置不能为空")
    @Valid
    private AliSmsProperty ali;

    /**
     * 华为短信配置
     */
    @NotNull(message = "华为短信配置不能为空")
    @Valid
    private HuaweiSmsProperty hw;

    @Getter
    @Setter
    public static class AliSmsProperty extends BaseEntity {

        /**
         * 地区节点
         */
        @NotBlank(message = "地区节点不能为空")
        private String endPoint;

        /**
         * 连接键
         */
        @NotBlank(message = "连接键不能为空")
        private String accessKeyId;

        /**
         * 连接密钥
         */
        @NotBlank(message = "连接密钥不能为空")
        private String accessKeySecret;

        /**
         * 地区id
         */
        @NotBlank(message = "地区id不能为空")
        private String regionId;

    }

    @Getter
    @Setter
    public static class HuaweiSmsProperty extends BaseEntity {

        /**
         * 请求节点地址
         */
        @NotBlank(message = "请求节点地址不能为空")
        private String endpoint;

        /**
         * 应用键
         */
        @NotBlank(message = "应用键不能为空")
        private String appKey;

        /**
         * 应用密钥
         */
        @NotBlank(message = "应用密钥不能为空")
        private String appSecret;

        /**
         * 回调地址
         */
        private String callbackUrl;

    }
}
